class Collects ce e| ce -> e where
      
empty  :: ce
insert :: e -> ce -> ce
member :: e -> ce -> Bool

data BinTree a = Branch a (BinTree a) (BinTree a) | Leaf
	deriving Show

instance (Eq a, Ord a) => Collects (BinTree a) a where

empty = Leaf

insert x Leaf = Branch x Leaf Leaf
insert x (Branch root ri rd)	|x == root = Branch root ri rd
				|x > root = Branch root ri (insert x rd)
				|otherwise = Branch root (insert x ri) rd
				
member x Leaf = False
member x (Branch root ri rd)	|x == root = True
				|x > root = member x rd
				|otherwise = member x ri
